<!DOCTYPE html>

<html class="no-js">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title></title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <script src="https://cdn.staticfile.org/axios/0.19.0-beta.1/axios.js"></script>
  <script src="https://cdn.staticfile.org/vue/2.5.17/vue.js"></script>
  <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.13.0/theme-chalk/index.css" />
  <script src="https://cdn.staticfile.org/element-ui/2.13.0/index.js"></script>

  <link rel="stylesheet" href="../../../lib/index.css" />
  <script src="../../../lib/avue.js"></script>
</head>

<body>
  <div id="app">
    <avue-form :option="option" ref="form" v-model="form"></avue-form>
  </div>
</body>
<script>
  new Vue({
    el: '#app',
    data() {
      return {
        form: {
          text1: 0,
          text2: '文本2',
        },
        option: {
          column: [{
            label: '内容0',
            prop: 'text',
            type: 'number',
          }, {
            label: '内容1',
            prop: 'text1',
            type: 'radio',
            dicData: [{
              label: '隐藏',
              value: 0
            }, {
              label: '显示',
              value: 1,
            }]
          }, {
            label: '内容2',
            prop: 'text2',
            display: true,
          }]
        }
      }
    },
    watch: {
      'form.text1'() {
        var index = this.$refs.form.findColumnIndex('text2')
        var column = this.option.column[index];
        if (this.form.text1 === 0) {
          column.display = true
        } else {
          column.display = false
        }
      }
    }
  })
</script>

</html>